<html>
	<head>
		<script src="../../src/gears_init.js"></script>
		<script src="../../src/Norm.js"></script>
		<script src="../../src/Norm.Logger.Gears.js"></script>
		<script src="../../src/Norm.Database.Gears.js"></script>
		<script src="../../src/Norm.ResultIterator.Gears.js"></script>
		<script src="../../src/Norm.LastIdManager.js"></script>
		<script src="../../src/Norm.Events.js"></script>
		<script src="../../src/Norm.Sql.js"></script>
		<script src="../../src/Norm.Fields.js"></script>
		<script src="../../src/Norm.Model.js"></script>
		<script src="../../src/Norm.Introspection.js"></script>
		<script src="../../src/Norm.Transaction.js"></script>
		<script>
			Norm.Database.name = "test.simple1";
			var Person = new Norm.Model({
				name : "Person",
				fields :  {
					firstName : new Norm.Fields.String({maxLength : 25}),
					lastName : new Norm.Fields.String({maxLength : 25})
				}
			});
			
			var Tests = {
				
				up : function() {
					
					Person.dropTable();
					Person.createTable();
				},
				
				"test a lot of insert in transaction" : function() {
					
					 Norm.Transaction(function() {
					 	
					 	for (var i = 0; i < 100; i++) {
							new Person({firstName:"test",lastName:"test"}).save();
					 	}
					 });
					 UnitTest.assertEqual(100, Person.select().toArray().length);
				},
				
				"test a lot of update in transaction" : function() {
					
					var person = Person.select().getOne();
					Norm.Transaction(function() {
						
						for (var i = 0; i < 100; i++) {
							person.firstName = i.toString();
							person.save();
						}
					});
					UnitTest.assertEqual("99", Person.select().getOne().firstName);
				},
				
				down : function() {
					Person.dropTable();
				}
			};
		</script>
		<script src="unit-test.js"></script>
	</head>
	<body>
		
	</body>
</html>